<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>우편 번호 찾기</title>
<link rel="stylesheet" href="../css/board.css" type="text/css">
<script type="text/javascript">
	function searchCheck(){
		if(document.search.keyWord.value==''){
			alert('검색어를 입력하세요');
			document.search.keyWord.focus();
			return false;
		}
	}
	 function insertZip(zipcode,sido,gugun,dong) {
	 	opener.document.command.uzipcode.value=zipcode;
		opener.document.command.uaddr.value=sido+" "+gugun+" "+dong;
		opener.document.command.uresaddr.value="";
		self.close();
	}
</script>
</head>
<body>

<form action="zipForm.do" name="search" method="get" onsubmit="return searchCheck()">
<table width="400" align="center" border="1" cellspacing="0"
                                            cellpadding="2">
                                            
	<tr>
	<td align="center">
<!--  			<select name="keyField">
				<option value="gugun">구/군</option>
				<option value="sido">시도</option>
				<option value="dong">동</option>
				<option value="bunji">번지</option>
			</select> -->
			주소 검색 :  
		</td>
		<td>
			<input type="text" size="16" name="keyWord">
		</td>
		<td>
			<input type="submit" value="찾기">
		</td>
	</tr>                                            
</table><br>
(동으로 검색하실 때는 "동"자 을 빼고 검색하셔야 더 정확하게 검색 됩니다.)
<table width="100%" border="0" cellspacing="0" cellpadding="2">
	<tr bgcolor="#F3F3F3">
		<th width="50">주  소</th>
	</tr>
	<tr bgcolor="#777777">
		<td height="1" colspan="5"></td>
	</tr>
	<c:forEach var="zip" items="${list}">
	<tr>
		
		<td onclick="insertZip( '${zip.zipcode}','${zip.sido}','${zip.gugun}','${zip.dong}')">
			${zip.zipcode}	 ${zip.sido} 	 ${zip.gugun}	 ${zip.dong}  </td>
					
		</tr>	
	</c:forEach>
</table>
</form>
</body>
</html>